package com.hyacinth.seckill.repository;

import com.hyacinth.wapper.PageCond;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 基础持久层接口
 * Version: V1.0
 * Author: spring
 * Date: 2016/5/3
 */
@NoRepositoryBean
public interface BaseRepository<T extends Serializable, ID extends Serializable> extends JpaRepository<T, ID> {

    List<T> query(String hql);
    List<T> query(Class<T> tClass);
    List<T> query(String hql, int maxCount);
    List<T> query(String hql, Object[] paramValues);
    List<T> query(String hql, Map<String, Object> paramMap);
    long queryForCount(String hql, Map<String, Object> paramMap);
    List<T> queryWithPage(String hql, int begin, int fetchSize);
    List<T> queryWithPage(String hql, Map<String, Object> paramMap, PageCond page);

    List<Long> queryIds(String sql);
    long querySQLForCount(String sql);
    Object sumWithSql(String sql);
    List<Object[]> queryWithSQL(String sql);
    List<T> queryWithSQL(String sql, Class<T> clazz);
    List<T> queryWithSQLAndPage(String sql, Class<T> clazz, PageCond page);
    List<Object[]> queryWithSQLOfBatch(String sql, int beginCount, int batchCount);
    List<Map<String, Object>> queryMapWithSQLOfBatch(String sql, int beginCount, int batchCount);

    int excuteBySql(String sql);
    @Transactional
    void batchInsert(List listA);
}
